//
//  HTHomeTableViewCell.m
//  HappyTravel
//
//  Created by JiePan’s Mac on 2018/8/3.
//  Copyright © 2018年 Apple. All rights reserved.
//

#import "HTHomeTableViewCell.h"

@implementation HTHomeTableViewCell

#pragma mark - init
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self.contentView addSubview:self.imgView];
        [self.contentView addSubview:self.placeLabel];
        [self.contentView addSubview:self.dateLabel];
        [self.contentView addSubview:self.phoneBtn];
        [self.contentView addSubview:self.deleteBtn];
    }
    return self;
}

#pragma mark - touches events
- (void)actionOfClickPhoneBtn:(UIButton *)button {
    
    if (self.didClickPhoneBtnBlock) {
        self.didClickPhoneBtnBlock(button);
    }
}

- (void)actionOfClickDeleteBtn:(UIButton *)button {
    
    if (self.didClickDeleteBtnBlock) {
        self.didClickDeleteBtnBlock(button);
    }
}

#pragma mark - getter
- (UIImageView *)imgView {
    return _imgView ?: ({
        _imgView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 22, 36, 36)];
        _imgView.image = [UIImage imageNamed:@"icon_plan"];
        _imgView;
    });
}

- (UILabel *)placeLabel {
    return _placeLabel ?: ({
        _placeLabel = [[UILabel alloc]initWithFrame:CGRectMake(66, 15, 200, 25)];
        _placeLabel.text = @"New York - Paris";
        _placeLabel.textColor = UIColorOfHex(0x3B3C4A);
        _placeLabel.font = [UIFont systemFontOfSize:14];
        _placeLabel;
    });
}

- (UILabel *)dateLabel {
    return _dateLabel ?: ({
        _dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(66, CGRectGetMaxY(self.placeLabel.frame), 200, 25)];
        _dateLabel.text = @"2018-08-09 10:30";
        _dateLabel.textColor = UIColorOfHex(0x999999);
        _dateLabel.font = [UIFont systemFontOfSize:13];
        _dateLabel;
    });
}

- (UIButton *)phoneBtn {
    return _phoneBtn ?: ({
        _phoneBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _phoneBtn.frame = CGRectMake(ScreenWidth-30-53, 30, 18, 18);
        [_phoneBtn setBackgroundImage:[UIImage imageNamed:@"phone"] forState:UIControlStateNormal];
        [_phoneBtn addTarget:self action:@selector(actionOfClickPhoneBtn:) forControlEvents:UIControlEventTouchUpInside];
        _phoneBtn;
    });
}

- (UIButton *)deleteBtn {
    return _deleteBtn ?: ({
        _deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _deleteBtn.frame = CGRectMake(ScreenWidth-30, 32, 15, 15);
        [_deleteBtn setBackgroundImage:[UIImage imageNamed:@"delete"] forState:UIControlStateNormal];
        [_deleteBtn addTarget:self action:@selector(actionOfClickDeleteBtn:) forControlEvents:UIControlEventTouchUpInside];
        _deleteBtn;
    });
}






@end
